package project.impl;

import java.util.HashMap;
import java.util.Map;

import project.dao.IUserDao;
import project.entity.User;

public class UserDaoImpl implements IUserDao {

	private static final Map<String, User> userMap = new HashMap<>();

	static {
		userMap.put("test01", new User("test01", "123"));
		userMap.put("test02", new User("test02", "723"));
		userMap.put("test03", new User("test03", "124"));
		userMap.put("test04", new User("test04", "173"));
	}

	@Override
	public User findByUsernameAndPassword(String username, String password) {

		User user = userMap.get(username);
		if (user == null)
			return null;

		return password.equals(user.getPassword()) ? user : null;
	}

//	public static void main(String[] args) {
//		IUserDao dao = new UserDaoImpl();
//		System.out.println(dao.findByUsernameAndPassword("test01", "123"));
//	}

}
